package com.ywd.materials.admin.controller;

import com.ywd.materials.admin.common.Common;
import com.ywd.materials.admin.common.CommonGoods;
import com.ywd.materials.admin.dto.query.MaterialsGoodsPkgQuery;
import com.ywd.materials.admin.exception.R;
import com.ywd.materials.admin.exception.RPage;
import com.ywd.materials.admin.service.impl.MaterialsGoodsPkgServiceImpl;
import com.ywd.materials.admin.service.impl.MaterialsGoodsServiceImpl;
import com.ywd.materials.admin.service.impl.MaterialsGoodsTypeServiceImpl;
import com.ywd.materials.admin.service.impl.MaterialsWarehouseServiceImpl;
import com.ywd.materials.admin.vo.MaterialsGoodsPkgVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lk
 * @date 2024/4/17 13:53
 */
@AllArgsConstructor
@RestController
@RequestMapping("/goodsPkg")
@Tag(name = "库存管理")
public class MaterialsGoodsPkgController {

    private final MaterialsGoodsPkgServiceImpl materialsGoodsPkgServiceImpl;
    private final MaterialsWarehouseServiceImpl materialsWarehouseServiceImpl;
    private final MaterialsGoodsTypeServiceImpl materialsGoodsTypeServiceImpl;
    private final MaterialsGoodsServiceImpl materialsGoodsServiceImpl;

//    @PostMapping("/saveGoodsPkg")
//    @Operation(summary = "新增库存")
//    public R<Boolean> saveGoodsPkg(@Validated @RequestBody MaterialsGoodsPkgDto dto) {
//        return R.ok(materialsGoodsPkgServiceImpl.saveGoodsPkg(dto));
//    }
//
//    @PutMapping("/updateGoodsPkg")
//    @Operation(summary = "修改库存")
//    public R<Boolean> updateGoodsPkg(@Validated @RequestBody MaterialsGoodsPkgDto dto) {
//        return R.ok(materialsGoodsPkgServiceImpl.updateGoodsPkg(dto));
//    }
//
//    @DeleteMapping("/deleteGoodsPkg")
//    @Operation(summary = "删除库存")
//    public R<Boolean> deleteGoodsPkg(@Schema(description = "ID") @RequestParam Long id) {
//        return R.ok(materialsGoodsPkgServiceImpl.deleteGoodsPkg(id));
//    }

    @PostMapping("/getGoodsPkgPage")
    @Operation(summary = "查询库存列表(分页)")
    public R<RPage<List<MaterialsGoodsPkgVo>>> getGoodsPkgPage(@RequestBody MaterialsGoodsPkgQuery query) {
        return R.ok(materialsGoodsPkgServiceImpl.getGoodsPkgPage(query));
    }

    @GetMapping("/getGoodsPkgPartList")
    @Operation(summary = "仓库列表(筛选项)")
    public R<List<Common>> getGoodsPkgPartList(@Schema(description = "名称") @RequestParam(required = false) String name) {
        return R.ok(materialsWarehouseServiceImpl.getWarehouseListCommon(name));
    }

    @GetMapping("/getGoodsTypePartList")
    @Operation(summary = "物资类型列表(筛选项)")
    public R<List<Common>> getGoodsTypePartList(@Schema(description = "名称") @RequestParam(required = false) String name) {
        return R.ok(materialsGoodsTypeServiceImpl.getGoodsTypePartList(name));
    }
    @GetMapping("/getGoodsPartList")
    @Operation(summary = "物资列表(筛选项)")
    public R<List<CommonGoods>> getGoodsPartList(@Schema(description = "名称") @RequestParam(required = false) String name) {
        return R.ok(materialsGoodsServiceImpl.getGoodsPartList(name));
    }


}
